package com.example.camerademo.util;

import java.io.ByteArrayOutputStream;
import java.io.InputStream;

/**
 * author: wj
 * created on: 2021/4/2 16:57
 * description:
 */
public class StreamTool {

    /**
     * 从流中读取数据
     * @param inStream
     * @return
     * @throws Exception
     */
    public static byte[] read(InputStream inStream) throws Exception{
        ByteArrayOutputStream outStream = new ByteArrayOutputStream();
        byte[] buffer = new byte[1024];
        int len = 0;
        while((len = inStream.read(buffer)) != -1)
        {
            outStream.write(buffer,0,len);
        }
        inStream.close();
        return outStream.toByteArray();
    }
}
